<?php
namespace app\admin\controller;
use think\facade\Db;
use think\facade\View;
class SysLog extends Base
{
    public function index(){
        //$map = $this->_search();
        if(IS_AJAX){
            $page = input('page');
            $limit = input('limit')?:15;
            $map = [];
            if(input('content')){
                $map['content'] = ['like','%'.input('username').'%'];
            }
            if(input('time_start') && input('time_end')){
                $time_start = strtotime(input('time_start'));
                $time_end = strtotime(input('time_end'));
                $map['reg_time'] = ['between',[$time_start,$time_end]];
            }
            $count = Db::name('sys_log')->where($map)->count();
            $field = '*';
            $list = Db::name('sys_log')
                ->field($field)
                ->where($map)
                ->order('id desc ')
                ->page($page,$limit)
                ->select();
            return json(['code'=>0,'msg'=>'查询成功','count'=>$count,'data'=>$list]);
        }
        $level_arr = Db::name('user_level')->field('level_name,rank')->select();
        View::assign('level_arr',$level_arr);
        $wallet_arr = logic('Wallet')->getName();
        View::assign('wallet_arr',$wallet_arr);
        return View::fetch();
    }
}